package org.activision.model;

import java.io.Serializable;

import org.activision.model.player.Player;
import org.activision.content.combat.Combat;
import org.activision.util.RSTile;

public abstract class Entity implements Serializable {

	private static final long serialVersionUID = -2311863174114543259L;

	private RSTile location;

	private transient Walking walk;
	private transient Combat combat;

	private transient int Index;
	private transient boolean hidden;

	public void setIndex(int index) {
		Index = index;
	}

	public int getIndex() {
		return Index;
	}

	public int getClientIndex() {
		if (this instanceof Player) {
			return this.Index + 32768;
		} else {
			return this.Index;
		}
	}
	
	public boolean isDead() {
		if (this instanceof Player) {
			return ((Player)this).getSkills().isDead();
		}
		return true;
	}

	public abstract void heal(int amount);

	public abstract void hit(int damage);

	public abstract void turnTemporarilyTo(Entity entity);
	public abstract void turnTo(Entity entity);

	public abstract void resetTurnTo();

	public abstract void graphics(int id);

	public abstract void graphics(int id, int delay);

	public abstract void graphics2(int id);

	public abstract void graphics2(int id, int delay);

	
	public abstract void animate(int id);

	public abstract void animate(int id, int delay);

	public void EntityLoad() {
		this.setWalk(new Walking(this));
		this.setCombat(new Combat(this));
		this.setHidden(false);
	}

	public void setHidden(boolean hidden) {
		this.hidden = hidden;
	}

	public boolean isHidden() {
		return hidden;
	}

	public void setLocation(RSTile location) {
		this.location = location;
	}

	public RSTile getLocation() {
		return location;
	}

	public void setWalk(Walking walk) {
		this.walk = walk;
	}

	public Walking getWalk() {
		return walk;
	}

	public void setCombat(Combat combat) {
		this.combat = combat;
	}

	public Combat getCombat() {
		return combat;
	}
	
	public boolean getSafeZone() {
		if ((getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3672 && getLocation().getY() <= 3695 || getLocation().getX() >= 2630 && getLocation().getX() <= 2667 && getLocation().getY() >= 9378 && getLocation().getY() <= 9398))
			return true;
				else if ((getLocation().getX() >= 2940 && getLocation().getX() <= 3395 && getLocation().getY() >= 3524 && getLocation().getY() <= 4000) || (getLocation().getX() >= 3264 && getLocation().getX() <= 3279 && getLocation().getY() >= 3279 && getLocation().getY() <= 3672) || (getLocation().getX() >= 2756 && getLocation().getX() <= 2875 && getLocation().getY() >= 5512 && getLocation().getY() <= 5627 || getLocation().getX() >= 2754 && getLocation().getX() <= 2375 && getLocation().getY() >= 5512 && getLocation().getY() <= 5131))	
			return false;
				else
			return true;
	    }
	
	public boolean inWildy() {
		if ((getLocation().getX() == 3000 && getLocation().getX() == 3492 && getLocation().getY() == 3523 && getLocation().getY() == 3974))
			return true;
		else
			return false;
	}
	}